package com.cskaoyan.javase._1extends._7initialization._1basic.classload;

/**
 * 触发子类的类加载,优先类加载父类
 * 而且是从最顶层父类开始进行类加载
 *
 * Object需不需要类加载呢?
 * 像JDK源码中的类也是需要类加载的
 * 但实际上源码中类,像String,Object这种,在启动JVM的时候,就已经类加载了
 * 轮不到启动main方法去类加载它
 *
 * @since 11:24
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo extends Father {
    static {
        System.out.println("demo");
    }

    // 启动main方法触发Demo类的类加载,会优先类加载父类Father
    public static void main(String[] args) {
        System.out.println("6666");
    }
}

class Father extends Grandfather {
    static {
        System.out.println("father");
    }
}
class Father2 extends Grandfather{}

class Grandfather {
    static {
        System.out.println("grandFather");
    }
}
